<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label">推流地址</label>
            <div class="layui-input-block">
                <input type="text" name="push" id="push" class="layui-input">
                <button type="button" class="layui-btn" onclick="copy('push')">复制</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">播流地址</label>
            <div class="layui-input-block">
                <input type="text" name="pull" id="pull" class="layui-input">
                <button type="button" class="layui-btn" onclick="copy('pull')">复制</button>
            </div>
        </div>
    </form>
</div>
<script>
    var id = "{$data.id}"
    console.log(id)

    function copy(name) {
        var Url2 = document.getElementById(name);
        Url2.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        alert("已复制好，可贴粘。");
    }

    layui.use(['jquery', 'form', 'upload', 'element', 'layer'], function () {
        var $ = layui.jquery;
        var form = layui.form,
            upload = layui.upload,
            element = layui.element,
            layer = layui.layer;

        $.ajax({
            url: "{:url('buildLive')}",
            data: {id: id},
            success(res) {
                console.log(res)
                $("#pull").val(res.data.pull)
                $("#push").val(res.data.push)
            }
        })
    });
</script>